package service.impl;

import java.util.UUID;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import dao.CustomerDao;
import vo.Customer;
import service.CustomerManager;

@Service(value = "customerManagerImpl")
public class CustomerManagerImpl implements CustomerManager {

	@Resource(name = "customerDaoImpl")
	private CustomerDao customerDao;
	
	public void setCustomerDao(CustomerDao customerDao) {
		this.customerDao = customerDao;
	}
	
	@Override
	@Transactional
	public int addCustomer(Customer c) {
		c.setId(UUID.randomUUID().toString());
		return customerDao.addCustomer(c);
	}

	@Override
	public Customer findCustomerByName(String name) {
		return customerDao.findCustomerByName(name);
	}

	@Override
	public Customer findCustomerByNameAndPwd(String name, String pwd) {
		return customerDao.findCustomerByNameAndPwd(name, pwd);
	}

}
